/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ManageDAL;

import ManageBLL.BLLManufacture;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JOptionPane;

/**
 *
 * @author Pham
 */
public class DALManufacture {
    AccessDB access;
    BLLManufacture bllManu = null;
    //constructor
    public DALManufacture(){
        access = new AccessDB();
    }
    
    //method getAllManufacture
    public List<BLLManufacture> getListManu()
    {
        try{
            List<BLLManufacture> listManu = new ArrayList<>();
            String queryString = "select * from manufacture";
            ResultSet rs = access.executeQuery(queryString);
            while(rs.next()){
                listManu.add(new BLLManufacture(rs));
            }
            return listManu;
        }
        catch(Exception e){
            JOptionPane.showMessageDialog(null, e.getMessage());
            return null;
        }
    }
    
    //method getManu by ID
    public BLLManufacture getManuById(int Id)
    {
        try{
            String queryString = "select * from manufacture where manufacture_id = " + Id;
            ResultSet rs = access.executeQuery(queryString);
            while(rs.next())
            {
                bllManu = new BLLManufacture(rs);
            }
            return bllManu;
        }
        catch(Exception e)
        {
            JOptionPane.showMessageDialog(null, e.getMessage());
            return null;
        }
    }
    
    //method getManuby Name
    
}
